package io.renren.modules.mqtt.service.impl;

import io.renren.common.utils.DateUtils;
import io.renren.modules.device.service.TDeviceService;
import io.renren.modules.monitor.service.MonitorAlarmService;
import io.renren.modules.mqtt.entity.MqttEvent;
import io.renren.modules.mqtt.service.IEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * //Add the class description
 *
 * @author lhb
 * @date 2023/6/12
 */
@Service("alarmEventService")
public class AlarmEventService implements IEventService {

    @Autowired
    private MonitorAlarmService alarmService;
    @Override
    public boolean eventHandler(MqttEvent event) {
        Date eventTime = DateUtils.stringToDate(event.getEventTime(), DateUtils.DATE_TIME_PATTERN);
        return alarmService.updateAlarm(event.getTerminalNo(), event.getEventId(), event.getAlarmCode(), eventTime);
    }

    @Override
    public String getMessType() {
        return "alarmEventReport";
    }
}
